package com.shujia.profile.behavior.order

import com.shujia.profile.UserProfile
import com.shujia.util.SparkUtil
import org.apache.spark.sql.{DataFrame, SparkSession}

class UserProfileOrderMoney extends UserProfile {
  flagName = "orderMoney"

  /**
   * 用于提取用户画像的接口
   *
   * @param spark ： spark环境
   * @return
   */
  override def extractProfile(spark: SparkSession): DataFrame = {

    spark.sql(
      s"""
        |select
        |member_id as id,
        |sum(origin_price) as orderMoney
        |FROM
        |dwd.dwd_t_order_d_f
        |where ds='$ds'
        |GROUP BY member_id
        |
        |""".stripMargin)
  }
}

object UserProfileOrderMoney {
  def main(args: Array[String]): Unit = {
    //获取参数,在提交任务时，在包名后面增加的参数
    val ds: String = args.head
    //spark环境
    val spark: SparkSession = SparkUtil.getSession()

    new UserProfileOrderMoney().run(spark, ds)
  }
}

